﻿ using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Windows.Controls;
using System.Globalization;
using VMuktiAPI;

namespace VMuktiGrid
{
    //public class CPODHeight : IValueConverter
    //{
    //    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        if (value == null)
    //        {
    //            return 0.0;
    //        }

    //        if (((Visibility)value) == Visibility.Collapsed)
    //        {
    //            return 25.0;
    //        }
    //        else if (((Visibility)value) == Visibility.Visible)
    //        {
    //            return ((ScrollViewer)parameter).Height + 25.0;
    //        }
    //        else
    //        {
    //            return 0.0;
    //        }
    //    }

    //    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    //    {
    //        return null;
    //    }
    //}


    public class CTabControlHeight : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value == null)
                {
                    return 0.0;
                }
                if (double.Parse(value.ToString()) > 0)
                {
                    return double.Parse(value.ToString());
                }
                else
                {
                    return 0.0;
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "Convert()--:--CgrdBuddyHeight.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                return null;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "ConvertBack()--:--CgrdBuddyHeight.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
                return null;
            }
        }

    }

    public class CTabControlWidth : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value == null)
                {
                    return 0.0;
                }
                if (double.Parse(value.ToString()) > 0)
                {
                    return double.Parse(value.ToString());
                }
                else
                {
                    return 0.0;
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "Convert()--:--CgrdBuddyHeight.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                return null;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "ConvertBack()--:--CgrdBuddyHeight.cs--:--" + ex.Message + " :--:--");
                ClsException.LogError(ex);
                ClsException.WriteToErrorLogFile(ex);
                return null;
            }
        }

    }
}
